package com.complex.spring.advance.aop.base;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;

/**
 * 此代码不正确的,要修改  IntroductionInterceptor的实现
 * @author gao
 *
 */
public class ProxyFactoryForIntroduction {
	public static void main(String[] args) {
		//织入器 ProxyFactory
		ProxyFactory weaver = new ProxyFactory(new Task());
		weaver.setInterfaces(new Class[]{ITask.class,IAdd.class});
		//设置advisor
		NameMatchMethodPointcutAdvisor advisor = new NameMatchMethodPointcutAdvisor();
		advisor.setMappedNames(new String[]{"execute"});
		advisor.setAdvice(new PerformanceMethodInterceptor());
		/**设置advisor*/
		weaver.addAdvisor(advisor);
		/**取得代理对象*/		
		ITask proxyObject = (ITask)weaver.getProxy();
		//调用代理对象
		proxyObject.execute();
		System.out.println(proxyObject.getClass());
	}
}
